import random
# Set the seed to 42
random.seed(42)
# Generate random numbers
print(random.random())
print(random.random()) 0.6394267984578837
0.025010755222666936
2023-06-24
random module in Python provides functions for generating random numbers and making random selections from sequences.seed():seed() function is used to initialize the random number generator with a specific seed value.randint(a, b):randint() function returns a random integer between the specified inclusive range [a, b].random():random() function returns a random float between 0 and 1.choice(seq):choice() function returns a random element from the given sequence seq.shuffle(seq):shuffle() function randomly shuffles the elements in the given sequence seq.random module in Python?random.seed()random.randint()random.random()random.shuffle()random.randint(a, b) function returns a random integer between:random.random() function returns a random float between:random.random()random.seed()random.choice()random.shuffle()random.choice(seq) function returns:random.seed() function do?random.seed()random.randint()random.random()random.shuffle()random.shuffle(seq) function shuffles the elements in the given sequence:random.randint(5, 10)?random.random() function always returns:random.choice(seq) function can be used with which of the following data types?random.seed() function is commonly used when:random.shuffle(seq) function modifies the original sequence:random.choice(seq) function can be used to randomly select an element from which of the following?random.randint()random.random()random.choice()random.shuffle()random.shuffle(seq) function?random.randint(a, b) function can generate a random integer that includes both a and b.random.shuffle(seq) function can be used with sequences other than lists.-import random
# Exercise: Generate a list of random integers within a range
def generate_random_list(start, end, size):
random_list = [random.randint(start, end) for _ in range(size)]
return random_list
# Test the function
print(generate_random_list(1, 100, 5)) # Output: List of 5 random integers between 1 and 100[4, 95, 36, 32, 29]
0.7790758570502878
red
a) Generating random numbers and making random selections
a) random.seed()
a) a and b (inclusive)
a) 0 and 1 (inclusive)
c) random.choice()
d) A random element from the given sequence
b) Sets the seed value for the random number generator
d) random.shuffle()
c) In random order
c) A random integer between 5 and 10
b) A float between 0 and 1
d) All of the above
b) Repeating the same sequence of random numbers
a) True
b) To make the random numbers predictable
d) All of the above
b) random.random()
c) To randomly rearrange the elements in a sequence
a) True
a) TrueManish Patel